<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/common.jspf" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>test</title>

</head>
<script type="text/javascript">
    $(function() {
        $('#tt').treegrid({
            url:'${proPath}/catalog/select.action',
            idField:'id',
            treeField:'catagoryName',
            columns:[[
                {checkbox:true},
                {field:'id',title:'目录编号',width:60},
                {field:'catagoryName',title:'目录名',width:130},
                {field:'catagoryUrl',title:'目录链接',width:150},
                {field:'catagoryRight',title:'目录权限',width:50},
                {field:'catagoryType',title:'目录类型',width:50,
                    formatter: function(value,row,index){
                        var array = '${applicationScope.sysParamMap.catagory_type}';
                        return valueToText(array,value);
                    }},
                {field:'catagoryStatus',title:'目录状态',width:50,
                    formatter: function(value,row,index){
                        var array = '${applicationScope.sysParamMap.catagory_status}';
                        return valueToText(array,value);
                    }},
            ]],
            singleSelect:false,
            fitColumns:true,
            toolbar: [{
                iconCls: 'icon-save',
                text:'保存',
                handler: function(){
                    var oldWin = parent.$("iframe[title='角色管理']").get(0).contentWindow;//返回ifram页面文档（window)
                    var row =oldWin.$('#dg').datagrid("getSelected");
                    var arr = $('#tt').treegrid('getSelections');
                    var arr2=new Array();
                    for (var i=0;i<arr.length;i++)
                    {
                        arr2.push(arr[i].catagoryRight);
                    };
                    var arr3=JSON.stringify(arr2);
                    $.post("${proPath}/role/rolesetright.action",
                        {
                            name:arr3,
                            rows:row.roleId,
                        },
                        function(data){
                            parent.$('#win').window('close');
                        });
                }
            },'-',{
                iconCls: 'icon-back',
                text:'返回',
                handler: function(){
                    parent.$('#win').window('close');
                }
            }]
        });
    });
</script>
<body>
<!-- 右键菜单定义如下： -->

<table id="tt"></table>

</body>
</html>